﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SharedGenomics.Workbench.Core;

namespace SharedGenomics.Workbench.Services
{
    public class UserAuthenticationService : IAuthenticationService
    {
        public bool TryAuthenticate(UserCredentials uc, out string errorMessage)
        {
            try
            {
                using (var proxy = new DataService.DataServiceClient())
                {
                    uc.ApplyToWCFProxy<DataService.IDataService>(proxy);
                    bool auth = proxy.IsUserRegisteredForSharedGenomics();

                    errorMessage = String.Empty;
                    return true;
                }
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
                return false;
            }
        }
    }
}
